package com.iamk.finalthesis;

import java.io.File;
import java.io.IOException;

import weka.core.Instances;
import weka.core.converters.ArffLoader;

import com.iamk.util.GetData;
import com.jMEF.gmm.Image;

public class Train {
	private  String strData;
	String[] label = { "1", "2", "3", "4", "5", "6", "7" };
//	String[] label = { "1", "2", "3", "4", "5", "6", "7","8","9","10","11","12","13","14","15","16","17","18","19","20","21" };

	public Train(String strData) {
		// TODO Auto-generated constructor stub
		this.strData = strData;
	}
	public void processTrain() {
		// TODO Auto-generated method stub
		File f = new File(strData);
		long start = System.currentTimeMillis();
		double[][] temp;
		int k = 1;
		ArffLoader loader = new ArffLoader();
		Instances mInstances = null;
		try {
			loader.setFile(f);
			mInstances = loader.getDataSet();
			for (int i = 0; i < label.length; i++) {
				System.out.println(mInstances.numAttributes());
				temp = GetData.getSubMatrix(GetData.getData(mInstances,(Integer.parseInt(label[i]))), mInstances.numAttributes()-1);
				Image._loadMixtureModel("GMM_MSCR/label" + label[i] + ".mix",temp, k, mInstances.numInstances());
			}
			System.out.println("Finish");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public static void main(String[] args) {
	Train train=new Train("features_mscr_human_train_7_1504.arff");	
	train.processTrain();
	}
}
